﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Web.Http;
using WS.EKA.Core.DI;
using WS.EKA.ServiceInterface;
using WS.EKA.Model;
using System.Web;
using System.Web.Security;
using Newtonsoft.Json;
using WS.EKA.Portal.Filters;
using AttributeRouting.Web.Http;

namespace WS.EKA.Portal.Controllers
{
    public class RegionController : ControllerBase
    {
        private IRegion regionService;
        public RegionController(IRegion regionService)
        {
            this.regionService = regionService;
        }

        [GET("api/province/")]
        public List<Region> GetProvinceList()
        {
            return regionService.GetProvinceList();
        }

        /// <summary>
        /// Get Region by OrderID
        /// </summary>
        /// <param name="parentId">OrderID</param>
        /// <returns></returns>
        [GET("api/region/{parentId}")]
        public List<Region> GetByParentId(int parentId)
        {
            return regionService.GetByParentId(parentId);
        }

        /// <summary>
        /// Get Parent Region Code by child code
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        /// 
        [GET("api/region/parentcode/get/")]
        public string GetParentCode(string childCode)
        {
            return regionService.GetParentCode(childCode);    
        }
    }
}
